package com.mobileares.midp.widgets.model;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-7-20
 * Time: 9:30:29
 * To change this template use File | Settings | File Templates.
 */
public class PaginationModelDto<T> extends ListModelDto {

    public PaginationModelDto(List<T> list, int totalRecord) {
        super(list);
        this.totalRecord = totalRecord;
    }


    public PaginationModelDto(int totalRecord) {
        this.totalRecord = totalRecord;
    }

    public PaginationModelDto() {
    }


    private int totalRecord;

    public int getTotalRecord() {
        return totalRecord;
    }

    public void setTotalRecord(int totalRecord) {
        this.totalRecord = totalRecord;
    }

    public void addModelItem(Object ob, int index) {
        getModelData().add(index, ob);
        this.totalRecord++;
    }

    public void modifyModelItem(Object newOb, int index) {
        getModelData().remove(index);
        getModelData().add(index, newOb);
    }

    public void modifyModelItem(Object newOb, Object oldOb) {
        int index = getModelData().indexOf(oldOb);
        getModelData().remove(index);
        getModelData().add(index, newOb);
    }
}
